package com.chujian.system.sys.controller;

import com.chujian.framework.core.base.TsDataController;
import com.chujian.framework.core.tsdata.Result;
import com.chujian.sys.entity.SysUserLogin;
import com.chujian.wx.constant.ChujianWxConst;
import com.chujian.wx.vo.GetPhoneInfoVo;
import com.chujian.system.sys.service.SysUserLoginService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/open")
@RestController
@AllArgsConstructor
public class SysOpenController extends TsDataController {

    private final SysUserLoginService userLoginService;

    /**
     * 解析用户手机号
     *
     * @param appId
     * @param getPhoneInfoVo
     * @return
     */
    @PostMapping("/parseMaUserPhone")
    public Result<?> parseMaUserPhone(@RequestHeader(ChujianWxConst.APP_ID_HEADER) String appId, @RequestBody GetPhoneInfoVo getPhoneInfoVo) {
        SysUserLogin userLogin = userLoginService.parseMaUserPhone(appId, getPhoneInfoVo);
        return okRs(userLogin);
    }

    /**
     * 保存实名
     *
     * @param appId
     * @param userLogin
     * @return
     */
    @PostMapping("/saveRealName")
    public Result<?> saveRealName(@RequestHeader(ChujianWxConst.APP_ID_HEADER) String appId, @RequestBody SysUserLogin userLogin) {
        userLogin = userLoginService.saveRealName(appId, userLogin);
        return okRs(userLogin);
    }

}
